<?php

$menu = $this->menu;
$showPictures = (bool)$this->block->params['showPictures'];
$maxLevel = (bool)$this->block->params['maxLevel'];

?>
<ul class="menu">
<?php
$i = 0;
foreach ($menu->items as $item) {
	if ($item->isVisible) {
?>
	<li class="item level-1 <?php echo $this->escape($item->slug), (0 == $i ? ' first' : '') ?>">
		<a href="/<?php echo $this->escape($item->slug) ?>">
<?php 
		if ($showPictures && '' != $item->picture) {
?>
			<img src="<?php echo $this->escape($item->picture) ?>" alt="<?php echo $this->escape($item->name) ?>"/>
<?php
		}
?>
			<span><?php echo $this->escape($item->name) ?></span>
		</a>
<?php
		if (count($item->items) > 0 && (0 == $maxLevel || $maxLevel > 1)) {
?>
		<ul class="sub-menu">
<?php
			$j = 0;
			foreach ($item->items as $subItem) {
				if ($item->isVisible) {
?>
			<li class="item level-2 <?php echo $this->escape($subItem->slug), (0 == $j ? ' first' : '') ?>">
				<a href="/<?php echo $this->escape($item->slug), '/', $this->escape($subItem->slug) ?>">
<?php 
					if ($showPictures && '' != $subItem->picture) {
?>
					<img src="<?php echo $this->escape($subItem->picture) ?>" alt="<?php echo $this->escape($subItem->name) ?>"/>
<?php
					}
?>
					<span><?php echo $this->escape($subItem->name) ?></span>
				</a>
			</li>
<?php
					++$j;
				}
			}
?>
		</ul>
<?php
		}

		++$i;
?>
	</li>
<?php
	}
?>
<?php
}
?>
</ul>